/**
 * Copyright 2007 Igor Chaves Cananéa
 *
 * This file is part of PBSFW
 *
 * PBSFW is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; version 2 of the License.
 *
 * PBSFW is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
#ifndef _TASK_H_
#define _TASK_H_

#include <pcl.h>
#include <set>
#include "defines.h"
#include "memorylist.h"
using namespace std;

namespace pbsfw {
    class Process;
    class Task {
        private:
            USE_CMM(Task)
            simtime_t time;
            bool canExecute;

        protected:
            Process *p;

        public:
            Task(Process &p, simtime_t time)
                : time(time), canExecute(true), p(&p) {
            }


            virtual ~Task() {}

            simtime_t getTime() const {
                return this->time;
            }

            void cancelExecution() {
                this->canExecute = false;
            }

            bool executable() const {
                return this->canExecute;
            }

            virtual void run();

            bool operator==(const Task &t) const {
                return this->time == t.time && this->p == t.p;
            }

            bool operator<(const Task &t) const {
                return this->time < t.time;
            }

            Process *getProcess() {
                return this->p;
            }
    };
};

#endif
